package com.eduhzy.ttw.teacher.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eduhzy.ttw.commonsdk.decoration.DividerItemDecoration;
import com.eduhzy.ttw.teacher.mvp.model.entity.ChildAreaData;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.eduhzy.ttw.teacher.R;
import com.eduhzy.ttw.teacher.mvp.contract.MineSchoolContract;
import com.eduhzy.ttw.teacher.mvp.model.MineSchoolModel;
import com.jess.arms.di.scope.ActivityScope;
import com.mcxtzhang.indexlib.suspension.SuspensionDecoration;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * @author xubo
 * @date 2018-7-18 16:29:59
 */
@Module
public abstract class MineSchoolModule {

    @Binds
    abstract MineSchoolContract.Model bindMineSchoolModel(MineSchoolModel model);

    @ActivityScope
    @Provides
    static List<ChildAreaData> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static BaseQuickAdapter<ChildAreaData, AutoBaseViewHolder> provideActivityAdapter(List<ChildAreaData> list) {
        return new BaseQuickAdapter<ChildAreaData, AutoBaseViewHolder>(R.layout.rv_item_choose_area, list) {
            @Override
            protected void convert(AutoBaseViewHolder helper, ChildAreaData item) {
                helper.setText(R.id.tv_name, item.getAreaName());
            }
        };
    }

    @ActivityScope
    @Provides
    static SuspensionDecoration provideSuspensionDecoration(MineSchoolContract.View view, List<ChildAreaData> list) {
        return new SuspensionDecoration(view.getActivity(), list);
    }

    @ActivityScope
    @Provides
    static DividerItemDecoration provideDividerItemDecoration(MineSchoolContract.View view, List<ChildAreaData> list) {
        return new DividerItemDecoration(view.getActivity(), DividerItemDecoration.VERTICAL_LIST);
    }

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManger(MineSchoolContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

}